Skip to content

fix(receive): await Endpoint::close for iroh 0.97#124

Open
cbenhagen wants to merge 1 commit inton0-computer:mainfrom
cbenhagen:fix/iroh-endpoint-close-receive
Open

fix(receive): await Endpoint::close for iroh 0.97#124
cbenhagen wants to merge 1 commit inton0-computer:mainfrom
cbenhagen:fix/iroh-endpoint-close-receive

Conversation

@cbenhagen
Copy link

iroh 0.97 no longer closes connections gracefully when an Endpoint is dropped; you’re expected to await endpoint.close() before the last handle goes away (or you get the iroh::socket “dropped without close” error).

receive now clones the endpoint, runs the existing fetch/export logic in an inner async block, then close()s so that path runs on success and on ?/bail! errors. Ctrl+C closes the outer clone before exit. send is unchanged (Router::shutdown() already shuts the stack down).

Diff size: most of it is one extra indent level from wrapping the worker body; the behavioral change is small.

Test: CLI regression with RUST_LOG=iroh::socket=error and stderr checks, plus the usual byte equality check.

@n0bot n0bot bot added this to iroh Mar 21, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Mar 21, 2026
Comment on lines 1127 to 1135
@@ -1123,6 +1135,7 @@ async fn receive(args: ReceiveArgs) -> anyhow::Result<()> {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right point at which to close the endpoint might be before db2.shutdown().await, similar to below, instead of adding another layer of wrapping around fut :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈 sorry for the noise

@cbenhagen cbenhagen force-pushed the fix/iroh-endpoint-close-receive branch from 22e5291 to d2a0326 Compare March 24, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚑 Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants